<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWechatNews extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('wechat_news',['engine'=>'InnoDB'])->setComment('微信-图文');
        $table->addColumn(Column::string('media_id',100)->setNullable()->setComment('永久素材MediaID'));
        $table->addColumn(Column::string('local_url',300)->setNullable()->setComment('永久素材显示URL'));
        $table->addColumn(Column::string('article_id',60)->setNullable()->setComment('关联图文ID(用英文逗号做分割)'));
        $table->addColumn(Column::tinyInteger('is_deleted')->setDefault(0)->setComment('是否删除'));
        $table->addColumn(Column::bigInteger('create_by')->setDefault(0)->setComment('创建人'));
        $table->addTimestamps('create_at');
        $table->create();
    }
}
